package com.sunnay.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sunnay.entity.AutoFaceOrderEntity;
import com.sunnay.mapper.AutoFaceOrderMapper;
import com.sunnay.service.AutoFaceOrderService;
import com.sunnay.vo.auth.SystemUser;
import org.springframework.stereotype.Service;

@Service
public class AutoFaceOrderServiceImpl extends ServiceImpl<AutoFaceOrderMapper, AutoFaceOrderEntity> implements AutoFaceOrderService {
    @Override
    public void submitFace(SystemUser systemUser) {
        AutoFaceOrderEntity orderEntity = this.getOne(Wrappers.<AutoFaceOrderEntity>query().lambda().eq(AutoFaceOrderEntity::getWxId,systemUser.getWxId()));
        if(ObjectUtil.isEmpty(orderEntity)){
            orderEntity = new AutoFaceOrderEntity();
            orderEntity.setStatus("0");
            orderEntity.setWxId(systemUser.getWxId());
            this.save(orderEntity);
        }else{
            orderEntity.setStatus("0");
            this.updateById(orderEntity);
        }
    }
}
